package com.diver.flinkdemo.utils;

import java.math.BigDecimal;
import java.util.Optional;

/**
 * @author guofy
 * @create 19/5/24 下午4:36
 * <p>
 * 数据处理工具类
 **/
public class DataUtil {
    /**
     * 运动步数换算热量
     *
     * @param step
     * @return
     */
    public static String getHeatByStep(String step) {
        step = Optional.ofNullable(step).orElse("0");
        Integer heat = Integer.valueOf(step) * 20 / 1000;
        return String.valueOf(heat);
    }

    /**
     * 运动步数换算距离
     *
     * @param step
     * @return
     */
    public static String getDistance(String step) {
        step = Optional.ofNullable(step).orElse("0");
        double distance = Double.valueOf(step) * 60 / 100000d;
        double distance_d = new BigDecimal(distance).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
        return String.valueOf(distance_d);
    }

    public static void main(String[] args) {

        Boolean isAdd = false;
        if(isAdd == null){
            System.out.println("1");
        }
        System.out.println("2");
    }
}
